<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>用户文件列表</title>
</head>
<body>
<h5>欢迎：<span th:if="${session.user!=null}" th:text="${session.user.nickname}"></span> <a th:href="@{/user/logout}">退出</a></h5>
<p>文件只能保存七天，七天后自动删除！</p>
<h1>文件列表</h1>
<table border="1px">
  <tr>
    <th>Id</th>
    <th>文件原名称</th>
    <th>文件新名称</th>
    <th>文件后缀</th>
    <th>存储路径</th>
    <th>文件大小</th>
    <th>类型</th>
    <th>是否是图片</th>
    <th>下载次数</th>
    <th>上传时间</th>
    <th>操作</th>
  </tr>
  <tr th:if="${#arrays.length(files)>0}" th:each="file,fileState:${files}">
    <td><span th:text="${fileState.index+1}"></span></td>
    <td><span th:text="${file.oldFileName}"></span></td>
    <td><span th:text="${file.newFileName}"></span></td>
    <td><span th:text="${file.ext}"></span></td>
    <td><span th:text="${file.path}"></span></td>
    <td><span th:text="${file.size}"></span></td>
    <td><span th:text="${file.type}"></span></td>
    <td>
      <span th:if="${!file.isImg}">否</span>
      <img th:src="${file.path}+'/'+${file.newFileName}" th:if="${file.isImg}" width="100px" height="80px"/>
    </td>
    <td><span th:text="${file.downCounts}"></span></td>
    <td><span th:text="${#dates.format(file.uploadTime,'yyyy-MM-dd HH:mm')}"></span></td>
    <td>
      <a th:href="@{/file/download/{id}(id=${file.id})}">下载</a>
      <a th:href="@{/file/lookFile/{id}(id=${file.id})}" target="_blank">在线打开</a>
      <a th:href="@{/file/delete/{id}(id=${file.id})}" >删除</a>
    </td>
  </tr>
</table>
<hr>
<h5>上传文件</h5>
<form th:action="@{/file/upload}" method="post" enctype="multipart/form-data">
  <input type="file" name="file"/>
  <input type="submit" value="上传文件">
</form>
</body>
</html>